%% 图1 幅频图
t=linspace(0,50,100);
for i=1:100
    y(i)=sin(0.2*pi*t(i))*sin(2*pi*0.1*1.0312.^t(i)*t(i));
end
aw = 8; bw = 6;
figure(1);
set(gcf,'Units','centimeters','Position',[0*aw 1+0*bw aw bw]);
plot(t,y,'LineWidth',1.5)
axis([0 52 -1 1])
title('FM-AM')
xlabel('t','interpreter','latex');ylabel('y','interpreter','latex');
set(gca,'FontName','Times New Roman','FontSize',8)%设置坐标轴刻度字体名称，大小
exportgraphics(gcf,'D:\Program Files\MATLAB\R2021b\guzhangzhenduan\articlCode\figure\1-FM-AM.png')
%% 图2 幅频熵值分布图
[X,Y] = meshgrid(3:10,10:100);
t=linspace(0,50,100);
for i=1:100
    y(i)=sin(0.2*pi*t(i))*sin(2*pi*0.1*1.0312.^t(i)*t(i));
end
for i = 1 : 91
    for j = 1:8
        z(i,j)=diversity(y,X(i,j),Y(i,j));
    end
end
aw = 20; bw = 10;
figure(1);
set(gcf,'Units','centimeters','Position',[0*aw 1+0*bw aw bw]);
s=mesh(X,Y,z,z)
s.FaceColor = 'flat';
ylabel(colorbar,'Diversity entropy')
axis([2 10 0 100 0.75  0.95])
title("Diversity entropy of FM-AM signal",'interpreter','latex')
xlabel('Dimension m','interpreter','latex');
ylabel('partition intervals ε');
zlabel("Diversity entropy",'interpreter','latex')
set(gca,'FontName','Times New Roman','FontSize',8)%设置坐标轴刻度字体名称，大小
exportgraphics(gcf,'D:\Program Files\MATLAB\R2021b\guzhangzhenduan\articlCode\figure\2-FAentropy.png')

%% 图5 AND 图12 原始信号及分解图
aw = 20; bw = 16;
figure(1);
set(gcf,'Units','centimeters','Position',[0*aw 1+0*bw aw bw]);
subplot(7,1,1);
plot(fee(1:600,1),'LineWidth',2)
title("Initial time series signal")
xlabel("Time",'interpreter','latex')
ylabel("signal",'interpreter','latex')
labelx=["Imf1","Imf2","Imf3","Imf4","Imf5","Imf6"];
for i=2:7
    subplot(7,1,i);
    plot(feeVmd(i,1:600),'LineWidth',2);
    xlabel("Time",'interpreter','latex')
    ylabel("signal",'interpreter','latex')
    title(labelx(i-1))
end
set(gca,'FontName','Times New Roman','FontSize',8)%设置坐标轴刻度字体名称，大小
exportgraphics(gcf,'D:\Program Files\MATLAB\R2021b\guzhangzhenduan\articlCode\figure\12-feeVmd.png')
%% 图6 AND 图13 最优熵值图
aw = 20; bw = 12;
figure(1);
set(gcf,'Units','centimeters','Position',[0*aw 1+0*bw aw bw]);
subplot(6,1,1);
labelx=["Imf1","Imf2","Imf3","Imf4","Imf5","Imf6"];
for i=49:54
    subplot(6,1,i-48);
    plot(DEPSO(i,:),'LineWidth',2);
    ylabel(labelx(i-48),'interpreter','latex')
end
set(gca,'FontName','Times New Roman','FontSize',8)%设置坐标轴刻度字体名称，大小
exportgraphics(gcf,'D:\Program Files\MATLAB\R2021b\guzhangzhenduan\articlCode\figure\13-pode.png')
%% 图7 AND 图14普通熵值图
aw = 20; bw = 12;
figure(1);
set(gcf,'Units','centimeters','Position',[0*aw 1+0*bw aw bw]);
subplot(6,1,1);
labelx=["Imf1","Imf2","Imf3","Imf4","Imf5","Imf6"];
for i=1:6
    subplot(6,1,i);
    plot(features(1600:1800,i),'LineWidth',2);
    ylabel(labelx(i))
end
set(gca,'FontName','Times New Roman','FontSize',8)%设置坐标轴刻度字体名称，大小
exportgraphics(gcf,'D:\Program Files\MATLAB\R2021b\guzhangzhenduan\articlCode\figure\14-de.png')
%% pode结果图
aw = 25; bw = 12;
figure(1);
set(gcf,'Units','centimeters','Position',[0*aw 1+0*bw aw bw]);
label=[];
for i=1:9
    label=[label;i*ones(100,1)];
end
plot(label,'bo')
hold on
plot(yfit,'r*','MarkerSize',2)
grid on
title("result with poDE",'interpreter','latex')
xlabel('Order number','interpreter','latex')
ylabel('Class label','interpreter','latex')
legend('actual label','prediction label')
set(gca,'FontName','Times New Roman','FontSize',8)%设置坐标轴刻度字体名称，大小
exportgraphics(gcf,'D:\Program Files\MATLAB\R2021b\guzhangzhenduan\articlCode\figure\8-feeresult.png')
%% PoDE混淆矩阵
a = test(:,7);
b = yfit;
a = a';
b = b';
a = categorical(a);
b = categorical(b);
plotconfusion(a,b);
title("Confusion matrix",'interpreter','latex')
xlabel('Target','interpreter','latex')
ylabel('Output','interpreter','latex')
exportgraphics(gcf,'D:\Program Files\MATLAB\R2021b\guzhangzhenduan\articlCode\figure\feeCm.emf')
%% de结果图
aw = 25; bw = 12;
figure(1);
set(gcf,'Units','centimeters','Position',[0*aw 1+0*bw aw bw]);
label=[];
for i=1:10
    label=[label;i*ones(100,1)];
end
plot(label,'bo')
hold on
plot(yfit,'r*','MarkerSize',2)
grid on
title("result with DE",'interpreter','latex')
xlabel('Order number','interpreter','latex')
ylabel('Class label','interpreter','latex')
legend('actual label','prediction label')
set(gca,'FontName','Times New Roman','FontSize',8)%设置坐标轴刻度字体名称，大小
exportgraphics(gcf,'D:\Program Files\MATLAB\R2021b\guzhangzhenduan\articlCode\figure\9-feeresult.png')
%% DE混淆矩阵
a = test1(:,7);
b = yfit;
% a = a';
% b = b';
a = categorical(a);
b = categorical(b);
plotconfusion(a,b);
title("Confusion matrix",'interpreter','latex')
xlabel('Target','interpreter','latex')
ylabel('Output','interpreter','latex')
exportgraphics(gcf,'D:\Program Files\MATLAB\R2021b\guzhangzhenduan\articlCode\figure\feeCmde.emf')
%% box
subplot(1,2,1)
boxplot(DEPSO(49:54,:)');
grid on
ylabel("Diversity Entorpy")
xlabel("IMFs")
title("(a)")
subplot(1,2,2)
boxplot(features(1600:1800,:));
grid on
ylabel("Diversity Entorpy")
xlabel("IMFs")
title("(b)")
exportgraphics(gcf,'D:\Program Files\MATLAB\R2021b\guzhangzhenduan\articlCode\figure\box.emf')
%% scatter
for i =1:9
    subplot(1,2,1)
    scatter(train((1+(i-1)*50):(50+(i-1)*50),1),train((1+(i-1)*50):(50+(i-1)*50),2),'filled');
    hold on
end
title("scatter with poDE(a)")
xlabel('parameter optimization Diversity entropy of IMF1')
ylabel('parameter optimization Diversity entropy of IMF2')
for i =1:9
    subplot(1,2,2)
    scatter(train1((1+(i-1)*50):(50+(i-1)*50),1),train1((1+(i-1)*50):(50+(i-1)*50),2),'filled');
    hold on
end
title("scatter with DE(b)")
xlabel('Diversity entropy of IMF1')
ylabel('Diversity entropy of IMF2')
exportgraphics(gcf,'D:\Program Files\MATLAB\R2021b\guzhangzhenduan\articlCode\figure\scatter.emf')